home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group97a.txt
/
000002_icon-group-sender _Fri Jan 3 09:21:34 1997.msg
< prev
next >
Wrap
Internet Message Format
|
2000-09-20
|
2KB
Received: by cheltenham.cs.arizona.edu; Fri, 3 Jan 1997 17:23:19 MST
Message-Id: <1.5.4.32.19970103152134.0071bfe4@post.its.mcw.edu>
X-Sender: cdt@post.its.mcw.edu
X-Mailer: Windows Eudora Light Version 1.5.4 (32)
Mime-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Date: Fri, 03 Jan 1997 09:21:34 -0600
To: icon-group@cs.arizona.edu
From: Chris Tenaglia <cdt@post.its.mcw.edu>
Subject: RE: Help for Icon Neophyte
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Content-Length: 1724
I think this does basically the same thing. It solves the
case problem. map() coverts to lower case by default.
Your code looked more like classical icon. Mine uses
3gl style. This looks more boring, but if I want to
diddle the code, then I want the steps separated a little so
more can be added later easier. Also think about
your procedures. You can chunk things a dozen different
ways. Some are far more maintainable. For example,
my parse() procedure is general enough that I've re-used
it in a 1000 other icon programs. I think each procedure
should do one thing. If a procedure does several things
it becomes less re-usable and more likely to have side
effects if changed.
I've read both books. Dr. Corre's book is best read after
The Icon Programming Language. Dr. Corre's book helped
me understand string scanning. Until then I used string
scanning, borrowed from other programs, but didn't know
enough to write my own. I still don't get coexpressions
and I've been programming icon since 1987.
procedure main()
count := table(0)
while line := map(read()) do
{
words := parse(line,' ,.;:!?')
every count[!words] +:= 1
}
result := sort(count)
every pair := !result do write(pair[1]," : ",pair[2])
end
#
# parse a string into a list with respect to a delimiter
#
procedure parse(line,delims)
static chars
chars := &cset -- delims
tokens := []
line ? while tab(upto(chars)) do put(tokens,tab(many(chars)))
return tokens
end
Chris Tenaglia (system manager) | cdt@post.its.mcw.edu
Medical College of Wisconsin |
8701 W. Watertown Plank Rd. | Ce que vous voyez est
Milwaukee, WI 53226 (414)456-8765 | Ce que vous obtenez !